import React, { useRef } from "react";
//导入 pubsub-js
import PubSub from 'pubsub-js';

export default function Search() {
  let input = useRef();
  //声明一个函数
  let search = () => {
    //发布消息
    PubSub.publish('hero_keyword', input.current.value);
  }
  return (
    <div className="form">
      <input type="text" ref={input} />
      <button onClick={search}>搜索</button>
    </div>
  );
}
